<template>
    <div class="app-container">
        <el-table v-loading="loading" :data="list" max-height="700">
            <el-table-column type="selection" width="55" align="center" />
            <!-- <el-table-column label="id" align="center" prop="id" /> -->
            <el-table-column label="下载地址" align="center" prop="url" />
            <el-table-column label="状态" align="center" prop="">
                <template slot-scope="scope">
                    <span v-if="scope.row.type == 1">正在处理</span>
                    <span v-if="scope.row.type == 2">处理成功</span>
                    <span v-if="scope.row.type == 3">处理失败</span>
                </template>
            </el-table-column>
            <el-table-column label="创建时间" align="center" prop="newcreatetime" />
            <el-table-column label="下载地址创建时间" align="center" prop="newupdatetime" />
            <el-table-column label="下载内容数量" align="center" prop="countnums" />
            <el-table-column label="预计数据处理成功时间" align="center" prop="">
                <template slot-scope="scope">约 {{ scope.row.yujiminute }} 分钟</template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-download" v-if="scope.row.url != ''"
                        @click="handleDownload(scope.row)">下载
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />
    </div>
</template>
<script>
import { findAllDownUrl } from "@/api/daixiazai/index.js";

export default {
    data() {
        return {
            // 遮罩层
            loading: false,
            // 表格数据
            list: [],
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: false,
            // 总条数
            total: 0,
            queryParams: {
                pageNum: 1,
                pageSize: 10,
            },
        }
    },
    created() {
        this.getList();
    },
    methods: {
        /** 查询待下载列表 */
        async getList() {
            this.loading = true;
            let res = await findAllDownUrl(this.queryParams);
            if (res.code == 0) {
                this.list = res.rows;
                this.total = res.total;
                this.loading = false;
            }
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            selection.forEach(item => {
                this.searchdata.shopid = item.shopid;
            });
        },
        // 下载按钮点击事件
        handleDownload(row) {
         this.$download.name(row.url);
        }
    }
};
</script>